1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module adw.SpringAnimation; 26 27 private import adw.Animation; 28 private import adw.AnimationTarget; 29 private import adw.SpringParams; 30 private import adw.c.functions; 31 public import adw.c.types; 32 private import glib.ConstructionException; 33 private import gobject.ObjectG; 34 private import gtk.Widget; 35 36 37 /** 38 * A spring-based [class@Animation]. 39 * 40 * `AdwSpringAnimation` implements an animation driven by a physical model of a 41 * spring described by [struct@SpringParams], with a resting position in 42 * [property@SpringAnimation:value-to], stretched to 43 * [property@SpringAnimation:value-from]. 44 * 45 * Since the animation is physically simulated, spring animations don't have a 46 * fixed duration. The animation will stop when the simulated spring comes to a 47 * rest - when the amplitude of the oscillations becomes smaller than 48 * [property@SpringAnimation:epsilon], or immediately when it reaches 49 * [property@SpringAnimation:value-to] if 50 * [property@SpringAnimation:clamp] is set to `TRUE`. The estimated duration can 51 * be obtained with [property@SpringAnimation:estimated-duration]. 52 * 53 * Due to the nature of spring-driven motion the animation can overshoot 54 * [property@SpringAnimation:value-to] before coming to a rest. Whether the 55 * animation will overshoot or not depends on the damping ratio of the spring. 56 * See [struct@SpringParams] for more information about specific damping ratio 57 * values. 58 * 59 * If [property@SpringAnimation:clamp] is `TRUE`, the animation will abruptly 60 * end as soon as it reaches the final value, preventing overshooting. 61 * 62 * Animations can have an initial velocity value, set via 63 * [property@SpringAnimation:initial-velocity], which adjusts the curve without 64 * changing the duration. This makes spring animations useful for deceleration 65 * at the end of gestures. 66 * 67 * If the initial and final values are equal, and the initial velocity is not 0, 68 * the animation value will bounce and return to its resting position. 69 * 70 * Since: 1.0 71 */ 72 public class SpringAnimation : Animation 73 { 74 /** the main Gtk struct */ 75 protected AdwSpringAnimation* adwSpringAnimation; 76 77 /** Get the main Gtk struct */ 78 public AdwSpringAnimation* getSpringAnimationStruct(bool transferOwnership = false) 79 { 80 if (transferOwnership) 81 ownedRef = false; 82 return adwSpringAnimation; 83 } 84 85 /** the main Gtk struct as a void* */ 86 protected override void* getStruct() 87 { 88 return cast(void*)adwSpringAnimation; 89 } 90 91 /** 92 * Sets our main struct and passes it to the parent class. 93 */ 94 public this (AdwSpringAnimation* adwSpringAnimation, bool ownedRef = false) 95 { 96 this.adwSpringAnimation = adwSpringAnimation; 97 super(cast(AdwAnimation*)adwSpringAnimation, ownedRef); 98 } 99 100 101 /** */ 102 public static GType getType() 103 { 104 return adw_spring_animation_get_type(); 105 } 106 107 /** 108 * Creates a new `AdwSpringAnimation` on @widget. 109 * 110 * The animation will animate @target from @from to @to with the dynamics of a 111 * spring described by @spring_params. 112 * 113 * Params: 114 * widget = a widget to create animation on 115 * from = a value to animate from 116 * to = a value to animate to 117 * springParams = physical parameters of the spring 118 * target = a target value to animate 119 * 120 * Returns: the newly created animation 121 * 122 * Since: 1.0 123 * 124 * Throws: ConstructionException GTK+ fails to create the object. 125 */ 126 public this(Widget widget, double from, double to, SpringParams springParams, AnimationTarget target) 127 { 128 auto __p = adw_spring_animation_new((widget is null) ? null : widget.getWidgetStruct(), from, to, (springParams is null) ? null : springParams.getSpringParamsStruct(true), (target is null) ? null : target.getAnimationTargetStruct()); 129 130 if(__p is null) 131 { 132 throw new ConstructionException("null returned by new"); 133 } 134 135 this(cast(AdwSpringAnimation*) __p); 136 } 137 138 /** 139 * Gets whether @self should be clamped. 140 * 141 * Returns: whether @self is clamped 142 * 143 * Since: 1.0 144 */ 145 public bool getClamp() 146 { 147 return adw_spring_animation_get_clamp(adwSpringAnimation) != 0; 148 } 149 150 /** 151 * Gets the precision used to determine the duration of @self. 152 * 153 * Returns: the epsilon value 154 * 155 * Since: 1.0 156 */ 157 public double getEpsilon() 158 { 159 return adw_spring_animation_get_epsilon(adwSpringAnimation); 160 } 161 162 /** 163 * Gets the estimated duration of @self. 164 * 165 * Returns: the estimated duration 166 * 167 * Since: 1.0 168 */ 169 public uint getEstimatedDuration() 170 { 171 return adw_spring_animation_get_estimated_duration(adwSpringAnimation); 172 } 173 174 /** 175 * Gets the initial velocity of @self. 176 * 177 * Returns: the initial velocity 178 * 179 * Since: 1.0 180 */ 181 public double getInitialVelocity() 182 { 183 return adw_spring_animation_get_initial_velocity(adwSpringAnimation); 184 } 185 186 /** 187 * Gets the physical parameters of the spring of @self. 188 * 189 * Returns: the spring parameters 190 * 191 * Since: 1.0 192 */ 193 public SpringParams getSpringParams() 194 { 195 auto __p = adw_spring_animation_get_spring_params(adwSpringAnimation); 196 197 if(__p is null) 198 { 199 return null; 200 } 201 202 return ObjectG.getDObject!(SpringParams)(cast(AdwSpringParams*) __p); 203 } 204 205 /** 206 * Gets the value @self will animate from. 207 * 208 * Returns: the value to animate from 209 * 210 * Since: 1.0 211 */ 212 public double getValueFrom() 213 { 214 return adw_spring_animation_get_value_from(adwSpringAnimation); 215 } 216 217 /** 218 * Gets the value @self will animate to. 219 * 220 * Returns: the value to animate to 221 * 222 * Since: 1.0 223 */ 224 public double getValueTo() 225 { 226 return adw_spring_animation_get_value_to(adwSpringAnimation); 227 } 228 229 /** 230 * Gets the current velocity of @self. 231 * 232 * Returns: the current velocity 233 * 234 * Since: 1.0 235 */ 236 public double getVelocity() 237 { 238 return adw_spring_animation_get_velocity(adwSpringAnimation); 239 } 240 241 /** 242 * Sets whether @self should be clamped. 243 * 244 * Params: 245 * clamp = the new value 246 * 247 * Since: 1.0 248 */ 249 public void setClamp(bool clamp) 250 { 251 adw_spring_animation_set_clamp(adwSpringAnimation, clamp); 252 } 253 254 /** 255 * Sets the precision used to determine the duration of @self. 256 * 257 * Params: 258 * epsilon = the new value 259 * 260 * Since: 1.0 261 */ 262 public void setEpsilon(double epsilon) 263 { 264 adw_spring_animation_set_epsilon(adwSpringAnimation, epsilon); 265 } 266 267 /** 268 * Sets the initial velocity of @self. 269 * 270 * Params: 271 * velocity = the initial velocity 272 * 273 * Since: 1.0 274 */ 275 public void setInitialVelocity(double velocity) 276 { 277 adw_spring_animation_set_initial_velocity(adwSpringAnimation, velocity); 278 } 279 280 /** 281 * Sets the physical parameters of the spring of @self. 282 * 283 * Params: 284 * springParams = the new spring parameters 285 * 286 * Since: 1.0 287 */ 288 public void setSpringParams(SpringParams springParams) 289 { 290 adw_spring_animation_set_spring_params(adwSpringAnimation, (springParams is null) ? null : springParams.getSpringParamsStruct()); 291 } 292 293 /** 294 * Sets the value @self will animate from. 295 * 296 * Params: 297 * value = the value to animate from 298 * 299 * Since: 1.0 300 */ 301 public void setValueFrom(double value) 302 { 303 adw_spring_animation_set_value_from(adwSpringAnimation, value); 304 } 305 306 /** 307 * Sets the value @self will animate to. 308 * 309 * Params: 310 * value = the value to animate to 311 * 312 * Since: 1.0 313 */ 314 public void setValueTo(double value) 315 { 316 adw_spring_animation_set_value_to(adwSpringAnimation, value); 317 } 318 }